{% extends "bet_base.html" %}
{% block extra_styles %}
<link rel="stylesheet" type="text/css" href="{{ MEDIA_URL }}styles/style2.css" />
{%endblock%}
{% block content %}

<div id="maincontent">
<h1> Welcome to the Book. Here you can add bets and edit the outcomes of existing bets. </h1>
 
 <div class="bets">
 <h2> Expired Bets Inbox</h2>
 {% if expnew_count == 0 %}
No newly expired bets.
{%else%}
<form action="book" method="post">
 {% csrf_token %}
 <table cellspacing="10px">
  <thead>
 <tr>
 <th> Bet Description </th>
 <th> Price </th>
 <th> Expires </th>
 <th> Occurred   </th>
 <th> Did Not Occur  </th>
 </tr>
 </thead>
 <tbody>
 {% for bet in expired_new %}
 <tr>
 <td>{{bet.description}}</td>
 <td>${{bet.price}}</td>
<td>
 {% if bet.expired%}
{{bet.expired.date}} at {{bet.expired.time}}
 {%else%}
{{bet.expired}}
{%endif%}
</td>
<td> <input type="radio" onmousedown="this.__chk = this.checked" onclick="if (this.__chk) this.checked = false" name="bet{{bet.id}}" id="choice{{ forloop.counter}}" value="win" /></td>
<td> <input type="radio" onmousedown="this.__chk = this.checked" onclick="if (this.__chk) this.checked = false" name="bet{{bet.id}}" id="choice{{ forloop.counter}}" value="loss" /></td>
 
</tr>
 {% endfor %}
 </tbody>
 </table>
 <br>
 <input type="submit" value="Set Outcome!" />
</form>
{% endif %}
</div>
 
 
 <div class="bets">
 <h2> Active Bets </h2>
 {% if count == 0 %}
No active bets.
{%else%}
<form action="odds" method="post">
 {% csrf_token %}
 <table cellspacing="10px">
  <thead>
 <tr>
 <th> Bet Description </th>
 <th> Price </th>
 <th> Expires </th>
 <th> Change Odds </th>
  <th> Occurred Early </th>
 <th> Did Not Occur  </th>
 </tr>
 </thead>
 <tbody>
 {% for bet in bets %}
 <tr>
 <td>{{bet.description}}</td>
 <td>${{bet.price}}</td>
<td>
 {% if bet.expired%}
{{bet.expired.date}} at {{bet.expired.time}}
 {%else%}
{{bet.expired}}
{%endif%}
</td>
<td><input type="text" name="odds{{bet.id}}" id="odds{{ forloop.counter}}" /></td>
<td> <input type="radio" onmousedown="this.__chk = this.checked" onclick="if (this.__chk) this.checked = false" name="bet{{bet.id}}" id="choice{{ forloop.counter}}" value="win" /></td>
<td> <input type="radio" onmousedown="this.__chk = this.checked" onclick="if (this.__chk) this.checked = false" name="bet{{bet.id}}" id="choice{{ forloop.counter}}" value="loss" /></td>
</tr>
 {% endfor %}
 </tbody>
 </table>
 <br>
 <div class="buttondark">
 <input type="submit" value="Save" />
 </div>
</form>
{% endif %}
</div>
<br>
<div class="bets">
<h2> Add a Bet </h2>
<form action="add" method="post">
 {% csrf_token %}
 {{form.non_field_errors}}
 <div class="fieldWrapper">
 	{{ form.title.errors }}
 <label for="title">Title:</label>
 	{{ form.title }}
 	
 	{{ form.description.errors }}
 <label for="description">Description:</label>
 	{{ form.description }}
 	</div>
 	<br>
 	<div class="fieldWrapper">
 	{{ form.price.errors }}
 <label for="price">Price:</label>
 	{{ form.price }}
 
 	{{ form.amount.errors }}
 <label for="amount">Win Amount:</label>
 	{{ form.amount }}
 	 	</div>
 	 	<br>
 	 	<div class="fieldWrapper">
 <label for="expire_date">Expire Date:</label>
 	<input type="text" name="expire_date" id="id_expire_date" /> 
 	
 	<label for="expire_time">Expire Time:</label>
 	<input type="text" name="expire_time" id="id_expire_time" /> 
 	</div>
 	<br>
 	<div class="fieldWrapper">
 <label for="daily">Daily Bet?</label>
 	{{ form.daily }}
 	</div>
 	
     <div class="buttondark"><input type="submit" value="Add Bet!" /></div>
</form>
</div>


<script type="text/javascript">
  AnyTime.picker( "id_expire_date",
      { format: "%z-%m-%d", firstDOW: 1 } );
   AnyTime.picker( "id_expire_time",
      { format: "%H:%i" } );    
</script>
<style type="text/css">
  #id_expire_date { background-image:url("{{MEDIA_URL}}img/clock.png");
    background-position:right center; background-repeat:no-repeat;
    border:1px solid #FFC030;color:#3090C0;font-weight:bold}
    
    #id_expire_time { background-image:url("{{MEDIA_URL}}img/clock.png");
    background-position:right center; background-repeat:no-repeat;
    border:1px solid #FFC030;color:#3090C0;font-weight:bold}
    </style>

<br>
<div class = "bets">
<h2> Expired Bets </h2>
{% if exp_count == 0 %}
<h3>No expired bets.</h3>
{%else%}
 <table>
 <thead>
 <tr>
 <th> Bet Description </th>
 <th> Price </th>
 <th> Expired </th>
  <th> Occurred </th>
 </tr>
 </thead>
 <tbody>
 {% for bet in expired_old %}
 <tr>
 <td>{{bet.description}}</td>
 <td>${{bet.price}}</td>
 <td>
 {% if bet.expired%}
{{bet.expired.date}} at {{bet.expired.time}}
 {%else%}
{{bet.expired}}
{%endif%}
</td>
 <td>{%if bet.win %}Yes{%else%}No{%endif%} </td>
 </tr>
 {% endfor %}
 </tbody>
 </table>
{%endif%}
</div>

</div>
{% endblock %}